package aiingames.simulation.agent;


import com.vividsolutions.jts.geom.Coordinate;

import aiingames.simulation.network.Network;
import aiingames.simulation.network.Node;
import aiingames.simulation.server.Server;

public class RoutedAgent extends Agent {

	private Network net;
	private Coordinate to;

	public RoutedAgent(int id, Network net, Coordinate to) {
		super(id);
		this.net = net;
		this.to = to;
	}
	

	@Override
	public AgentAction perform(Server serv) {
		
	
		
		Coordinate loc = serv.getAgentLocation(this);
		Node nearestNode = this.net.getNearestNode(loc);
	
		Node toNode = this.net.getNearestNode(to);
		
		toNode.getCoordinate();
		
		
		
		
		Coordinate dest = new Coordinate(nearestNode.getCoordinate().x-loc.x,nearestNode.getCoordinate().y-loc.y);
		
		AgentAction a = new AgentAction(dest, 1);
		
		return a;
	}

}
